package test;

import com.onlinevideo.dao.impl.UserDaoImpl;
import com.onlinevideo.entity.Comment;
import com.onlinevideo.entity.Page;
import com.onlinevideo.entity.User;
import com.onlinevideo.entity.Video;
import com.onlinevideo.service.VideoService;
import com.onlinevideo.service.impl.HistoryServiceImpl;
import com.onlinevideo.service.impl.VideoServiceImpl;
import com.onlinevideo.util.PageUtils;
import com.onlinevideo.util.SQLUtils;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class A {
    VideoService videoService = new VideoServiceImpl();
    public static void main(String[] args) throws InterruptedException {

        boolean matches = "5208459076122935056".matches("[0-9]+");

    }
    @Test
    public void t() throws InterruptedException {
        for (int i = 0; i < 1000; i++) {
            System.out.println("在线视频测试 分类：游戏  肉装vn 第五集" + "第"+i+"秒");
            Thread.sleep(1000);
        }
    }
    @Test
    public void t1() throws InterruptedException {
        for (int i = 0; i < 1000; i++) {
            System.out.println("在线视频测试 分类：游戏  肉装vn 第二集" + "第"+i+"秒");
            Thread.sleep(1000);
        }
    }
    @Test
    public void t2() throws InterruptedException {
        UserDaoImpl userDao = new UserDaoImpl();
        User user = new User();
        user.setPassword("pass");
        List<User> users = userDao.queryForPageItems(0, 10, user);
        users.forEach(System.out::println);
    }

    @Test
    public void t3() throws InterruptedException {
        UserDaoImpl userDao = new UserDaoImpl();
        User user = new User();
        user.setUsername("0_0");
        Integer integer = userDao.queryForPageTotalCount(user);
        System.out.println(integer);
        Page<User> page = PageUtils.getPage(5, 1, userDao,user);
        page.getData().forEach(System.out::println);
    }

    @Test
    public void t4() throws InterruptedException {
        Map<String, Object> maps =new HashMap<>();

        Integer pageNo = null;
        maps.put("pageNo",pageNo);

        String pageNostre = (String)maps.get("pageNo");

        System.out.println(pageNostre);
    }
    @Test
    public void t45() throws InterruptedException, IOException {
        new File("/uploadFile/videos/1.mp4").delete();
    }


    @Test
    public void ts5() throws InterruptedException, IOException {
        System.out.println(SQLUtils.CreateQuerySql(Comment.class));
        System.out.println(SQLUtils.CreateInsertSql(Comment.class));
        System.out.println(SQLUtils.CreateUpdateSql(Comment.class));
    }

    @Test
    public void ts6() {
        long id = UUID.randomUUID().getLeastSignificantBits();
        System.out.println(id);
    }

    @Test
    public void a() {
        List<Video> videos = videoService.queryAll();
        videos.forEach(System.out::println);
    }
    @Test
    public void aa() {
       new HistoryServiceImpl().deleteByUserId(1L);
    }

}
